package com.nativetalk.controller.app.three.start;

import com.nativetalk.base.RetInfo;
import com.nativetalk.bean.member.TdNtMember;
import com.nativetalk.bean.start.TdNtStartPageIndex;
import com.nativetalk.common.Constants;
import com.nativetalk.common.ValidationMessages;
import com.nativetalk.common.util.JsonUtil;
import com.nativetalk.common.util.MemcachedKey;
import com.nativetalk.common.util.MemcachedUtils;
import com.nativetalk.controller.app.three.study.ThreeStudyController;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by lizhun on 15/12/9.
 */
@Controller
public class ThreeStartController {
    private static Logger logger = Logger.getLogger(ThreeStartController.class);

    /**
     * @Purpose  获取banner图信息,直播预告,主类别,课程
     * @version  2.1
     * @time     2015-05-09
     * @author   lizhun
     * @return   RetInfo
     */
    @RequestMapping(value="/app/6/start" ,method = {RequestMethod.GET,RequestMethod.POST} ,consumes = "application/json" )
    @ResponseBody
    public RetInfo list() {
        RetInfo retInfo = new RetInfo();
        Map<String, Object> map = new HashMap<>();
        try {
            //打印入参
            logger.info(Constants.prefix_in);

            TdNtStartPageIndex tdNtStartPageIndex = (TdNtStartPageIndex) MemcachedUtils.get(MemcachedKey.tdNtStartPageIndex);
            if (tdNtStartPageIndex != null) {
                map.put("start", tdNtStartPageIndex);
                retInfo.setMark(ValidationMessages.getValue("MARKYES"));
                retInfo.setTip("获取启动页成功");
                retInfo.setObj(map);
            } else {
                retInfo.setMark(ValidationMessages.getValue("MARKNO"));
                retInfo.setTip("暂无启动页");
                retInfo.setObj(map);
            }

            //打印出参
            logger.info(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        } catch (Exception e) {
            //记录错误日志
            retInfo = RetInfo.getServerErrorInfo();
            logger.error(e.getMessage(), e);

            //打印出参
            logger.error(Constants.prefix_out + JsonUtil.toJson(retInfo));
            return retInfo;
        }

    }
}


